<template>
    <div>
        <br>
        <p>你选中的元素, 累加的值和为:{{sum}}</p>                
        <span v-for="item in arr" :key="item">
            <input type="checkbox" :value="item" v-model="arrr">
            {{item}}
        </span>
    </div>
</template>
<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      arrr:[]  //保存用户选中的数字
    };
  },
 computed:{
    sum(){
      return this.arrr.reduce((sum,item)=>{
        return(sum+=item)
      },0)
    }
  }
};
</script>
<style>
</style>